package com.kuang.controller;

import com.alibaba.fastjson.JSONObject;
import com.kuang.pojo.loginLog;
import com.kuang.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class LogController {
    @Autowired
    @Qualifier("LogServiceImpl")
    private LogService logService;


    //查询等日志
    @ResponseBody
    @RequestMapping("/log")
    public String log(){
    List<loginLog> list=logService.queryLoginLog();
    int count=list.size();

    return "{ \"code\":200,\"message\":\"成功\",\"data\":" + JSONObject.toJSONString(list) + ",\"count\" :"+count+"}";
    }


    //删除登录日志
    @RequestMapping("/deleteLog")
    @ResponseBody
    public String deleteLog(int id){
        logService.deleteLog(id);
        String msg="1";
        return msg;
    }
}
